import axios from '../config.js'

export function getAddressList(type, page) {
    const url = 'mobile/address/getList'
    const data = {
        type: type,
        page: page,
    }
    return axios.get(url, { params: data })
}

export function getAddressInfo(id) {
    const url = 'mobile/address/getInfo'
    const data = {
        id: id,
    }
    return axios.get(url, { params: data })
}

export function saveAddressInfo(id, contactName, contactMobile, provinceCode, cityCode, sectionCode, streetCode, detailAddress, isDefault) {
    const url = 'mobile/address/saveInfo'
    const data = {
        id: id,
        contactName: contactName,
        contactMobile: contactMobile,
        provinceCode: provinceCode,
        cityCode: cityCode,
        sectionCode: sectionCode,
        streetCode: streetCode,
        detailAddress: detailAddress,
        isDefault: isDefault,
    }
    return axios.post(url, data)
}

export function deleteAddressInfo(id) {
    const url = 'mobile/address/deleteInfo'
    const data = {
        id: id,
    }
    return axios.get(url, { params: data })
}

export function setDefaultAddress(id) {
    const url = 'mobile/address/setDefault'
    const data = {
        id: id,
    }
    return axios.get(url, { params: data })
}
